home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / MULTIDLL.ZIP;1 / MULTIDLL.DOC < prev    next >
Encoding:
Text File  |  1994-05-02  |  4.0 KB  |  88 lines

  1. How to have a main .app and many .dll's sharing the common variables and files?
  2. ===============================================================================
  3. by Mander Li, May 1994.
  4.  
  5.  
  6. This question was first raised by Geoff Bomford in the Clarion EchoMail.
  7. I did some tests, and answered the question for one main .app and one .dll.
  8.  
  9. When I put all the common variables and files in a .dll, say DLL0.APP,
  10. it compiles OK and successfully produces DLL0.DLL.
  11.  
  12. Then I create another .app called DLL1.APP, which contains just a
  13. subroutine called DllForm. The DllForm accesses the common variables and
  14. files in DLL0.  After the source codes are generated, I manually add the
  15. EXTERNAL attribute to the common variables and files in the file DLL1.CLA.
  16. The compilation is OK, but the linker says "$xxx is unresolved in yyy",
  17. where xxx is a common variable name, and yyy is a .CLA filename.
  18.  
  19. Thanks to Jimmy Rogers, Nick Grasso and Gary Wegner for their replies in
  20. the Clarion EchoMail.  They pointed out that I should link DLL0.DLL into
  21. DLL1.APP as well.  This is done by inserting the DLL0.LIB as External
  22. Object Module in the Module Worksheet of DLL1.APP.  Now the linker
  23. successfully produces the DLL1.DLL, with many "xxx is duplicated (dll)"
  24. warning messages.  These warning messages can be ignored.
  25.  
  26. Finally I have a MultiDll.APP which has a Form to display and allow the
  27. user to modify the common variable and file.  The Form is called MainForm,
  28. it has a button to calls the DllForm in DLL1 to show that the DLL1 does
  29. share the same common variable and file buffer.
  30.  
  31. All the .APP and related files are included in this ZIP file.
  32.  
  33.  
  34. Installation
  35. ============
  36. I suggest you create the directory C:\CLARION3\TEST\MULTIDLL and unzip all
  37. the files into this directory.  Note that the .APP files are created in
  38. CDD 3.008.
  39.  
  40.  
  41. How to run the Demo
  42. ===================
  43. 1. Change directory to C:\CLARION3\TEST\MULTIDLL, and run CDD.  First
  44.    bring up the DLL0.APP, and press Alt-M is make the DLL0.DLL.  Then
  45.    bring up DLL1.APP, and press Alt-M is make the DLL1.DLL.  And bring
  46.    up MULTIDLL.APP, press Alt-A to make and run the program.
  47.  
  48. 2. Press ENTER or click the Change button to bring up the Form.  Enter
  49.    something in the Common Var1 field.  Then press Alt-G or click the
  50.    'Go to DLL' button is call the subroutine DllForm in DLL1.
  51.  
  52. 3. Note that all the field are blank.  This shows that the variable and
  53.    file buffer are not passed to the DLL.  This is because the variable
  54.    and the file are declared as non-External in all the .APP files.
  55.  
  56. 4. Now exit to DOS, and manually edit the files DLL1.CLA and MULTIDLL.CLA
  57.    as follows:
  58.  
  59.    Locate and change the line:    CommonVar1   STRING(10)
  60.                            to:    CommonVar1   STRING(10),external
  61.  
  62.    Locate and change the line:
  63.           testfile  FILE,PRE(tes),DRIVER('Clarion'),CREATE,RECLAIM
  64.    to:
  65.           testfile  FILE,PRE(tes),DRIVER('Clarion'),CREATE,RECLAIM,external('')
  66.  
  67. 5. Run CDD, bring up DLL1.APP.  Press Alt-L to re-compile and link
  68.    without re-generating the source codes.  Then bring up MULTIDLL.APP, and
  69.    press Alt-L.  When compilation and link edit is finished, press ENTER
  70.    to exit.  And then press Alt-R to run the program.
  71.  
  72. 6. Repeat step 2 above.  Note that this time the DllForm at the bottom
  73.    displays the same value as the calling Form.  This shows that both
  74.    the main program and the DLL share the same variables and file buffer.
  75.    If you change the value in the bottom form and press ENTER, the new
  76.    value is reflected in the calling Form as well.
  77.  
  78.  
  79. Checklist
  80. =========
  81. If you don't get the same result as described above, ensure that:
  82. 1. The modules DLL101.CLA in DLL1.APP has the 'Called From This DLL
  83.    Only' unchecked in the Module Attributes screen.
  84. 2. The changes in Step 4 above are still there in the file.
  85. 3. The DLL0.APP and DLL1.APP have the Project Settings as follows:
  86.        'Use Runtime Libraries' is unchecked
  87.        'Application Access Method is 'Procedure Call Library'
  88.